﻿using System;
using System.Collections.Generic;
using System.Text;

namespace OddUserManager.Model
{
    public class AppUser : Entity
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        public string UPassword { get; set; }

        /// <summary>
        /// 用户姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 邮箱地址
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string MobileNumber { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public int CreateUserId { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 上次登录时间
        /// </summary>
        public DateTime LastLoginTime { get; set; }

        /// <summary>
        /// 登录次数
        /// </summary>
        public int LoginTimes { get; set; }

        public int ColorName { get; set; }
        /// <summary>
        /// 是否已删除
        /// </summary>
        public int IsDeleted { get; set; }

        [DapperIgnore]
        public virtual ICollection<UserRoles> UserRoles { get; set; }
        //public AppDetailsUser Clone()
        //{
        //    AppDetailsUser detailsUser = new AppDetailsUser();
        //    detailsUser.Id = this.Id;
        //    detailsUser.UserName = this.UserName;
        //    detailsUser.Name = this.Name;
        //    detailsUser.Password = this.Password;
        //    detailsUser.Email = this.Email;
        //    detailsUser.CreateTime = this.CreateTime;
        //    detailsUser.CreateUserId = this.CreateUserId;
        //    detailsUser.IsDeleted = this.IsDeleted;
        //    detailsUser.LastLoginTime = this.LastLoginTime;
        //    detailsUser.LoginTimes = this.LoginTimes;
        //    detailsUser.MobileNumber = this.MobileNumber;
        //    detailsUser.Remarks = this.Remarks;
        //    return detailsUser;
        //}
    }

    public class Role : Entity
    {
        public string Code { get; set; }

        public string Name { get; set; }

        public int CreateUserId { get; set; }

        public DateTime? CreateTime { get; set; }

        public string Remarks { get; set; }
        [DapperIgnore]
        public virtual ICollection<RoleMenus> RoleMenus { get; set; }


    }
    public class UserRoles
    {
        public int UserId { get; set; }

        public int RoleId { get; set; }
        [DapperIgnore]
        public AppUser User { get; set; }
        [DapperIgnore]
        public Role Role { get; set; }

    }

    public class RoleMenus
    {
        public int RoleId { get; set; }
        public int MenuId { get; set; }
        [DapperIgnore]
        public Role Role { get; set; }
        [DapperIgnore]
        public Menus Menu { get; set; }
    }

    /// <summary>
    /// 功能菜单实体
    /// </summary>
    public class Menus : Entity
    {


        public Menus()
        {
            Url = "";
            Code = "";
        }
        /// <summary>
        /// 父级ID
        /// </summary>
        public int ParentId { get; set; }

        /// <summary>
        /// 父级名称
        /// </summary>
        [DapperIgnore]
        public string ParentName { get; set; }

        /// <summary>
        /// 序号
        /// </summary>
        public int SerialNumber { get; set; }

        /// <summary>
        /// 菜单名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 菜单编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 菜单地址
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// 类型：0导航菜单；1操作按钮。
        /// </summary>
        public int Type { get; set; }

        /// <summary>
        /// 菜单图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 菜单备注
        /// </summary>
        public string Remarks { get; set; }
    }
}
